package com.twu.biblioteca.factory;

import com.twu.biblioteca.BibliotecaApp;
import com.twu.biblioteca.Receiver;
import com.twu.biblioteca.Println;
import com.twu.biblioteca.User.User;

public class QueryAction extends BasicAction {
    public static QueryAction queryAction = null;

    private QueryAction() {

    }

    public synchronized static QueryAction getInstance() {
        if (queryAction == null) {
            queryAction = new QueryAction();
        }
        return queryAction;
    }

    @Override
    public void run(BibliotecaApp bibliotecaApp, Receiver receiver) {
        User borrower = bibliotecaApp.getBookShelf().getBorrower(inputQueryGoodsName(receiver, bibliotecaApp.getBookShelf()));
        if(borrower==null){
            Println.println(Println.NO_BORROWER);

        } else {
            Println.println(borrower.getAccount());
        }
    }
}
